<?php


class important extends connector {

	function important() {
		$this->softbase(true);
	}

	function oncenter() {
		parent::start_template();

		$db_table = db_prefix . 'admin_member';
		$db_where = "username='$this->esp_username'";
		$rsMember = $this->db->fetch_first('SELECT id,username,password,name,sex,intotime,intime,outtime,ipadd,hit,powergroup,inputclassid,isclass FROM ' . $db_table . ' WHERE ' . $db_where);
		$this->ectemplates->assign('username', $rsMember['username']);
		$this->ectemplates->assign('name', $rsMember['name']);
		if ($rsMember['sex'] == 1) {
			$rsMember['sextype'] = $this->lng['select_sex_1'];
		} else {
			$rsMember['sextype'] = $this->lng['select_sex_0'];
		}
		$this->ectemplates->assign('memberinfo', $rsMember);

		$db_table = db_prefix . 'admin_powergroup';
		if (empty($rsMember['powergroup']) && empty($rsMember['username'])) {
			exit('Cookie err');
		}
		$db_where = 'id=' . $rsMember['powergroup'];

		$rsPower = $this->db->fetch_first('SELECT id,powername,powerlist,delclass FROM ' . $db_table . ' WHERE ' . $db_where);

		$serverinfo['phpinfo'] = PHP_OS . ' / PHP v' . PHP_VERSION;
		$serverinfo['getprc'] = get_magic_quotes_gpc() ? 'ON' : 'OFF';
		$serverinfo['upinfo'] = @ini_get('file_uploads') ? ini_get('upload_max_filesize') : '<font color="red">' . $this->lng['management_login_phpinfo07'] . '</font>';
		$serverinfo['gdver'] = GD_VERSION;
		$serverinfo['register'] = @ini_get('register_globals') ? 'ON' : 'OFF';
		$serverinfo['safemode'] = @ini_get('safe_mode') ? 'ON' : 'OFF';
		$serverinfo['sqlver'] = mysql_get_server_info();
		$serverinfo['gzip'] = strstr($_SERVER["HTTP_ACCEPT_ENCODING"], "gzip") ? 'ON' : 'OFF';

		$db_table = db_prefix . 'lng';
		$db_where = "isopen=1 ORDER BY pid DESC,id DESC";
		$sql = ('SELECT id,lngtitle,lng FROM ' . $db_table . ' WHERE ' . $db_where);
		$rs = $this->db->query($sql);
		while ($rsLanlist = $this->db->fetch_assoc($rs)) {
			$lngarray[] = $rsLanlist;
		}
		$this->ectemplates->assign('lngarray', $lngarray);
		$this->ectemplates->assign('powerinfo', $rsPower);
		$this->ectemplates->assign('serverinfo', $serverinfo);
		$this->ectemplates->display('admin/admin_center');
	}

	function onhead() {
		parent::start_template();
		$this->ectemplates->assign('adminurl', admin_URL);
		$this->ectemplates->display('top');
	}

	function onhome() {
		parent::start_template();

		$db_table = db_prefix . 'admin_member';
		$db_where = "username='$this->esp_username'";
		$rsMember = $this->db->fetch_first('SELECT id,username,password,name,sex,intotime,intime,outtime,ipadd,hit,powergroup,inputclassid,isclass FROM ' . $db_table . ' WHERE ' . $db_where);
		$this->ectemplates->assign('username', $rsMember['username']);
		$this->ectemplates->assign('name', $rsMember['name']);
		if ($rsMember['sex'] == 1) {
			$rsMember['sextype'] = $this->lng['select_sex_1'];
		} else {
			$rsMember['sextype'] = $this->lng['select_sex_0'];
		}
		$this->ectemplates->assign('memberinfo', $rsMember);

		$db_table = db_prefix . 'admin_powergroup';
		if (empty($rsMember['powergroup']) && empty($rsMember['username'])) {
			exit('Cookie err');
		}
		$db_where = 'id=' . $rsMember['powergroup'];

		$rsPower = $this->db->fetch_first('SELECT id,powername,powerlist,delclass FROM ' . $db_table . ' WHERE ' . $db_where);

		$serverinfo['phpinfo'] = PHP_OS . ' / PHP v' . PHP_VERSION;
		$serverinfo['getprc'] = get_magic_quotes_gpc() ? 'ON' : 'OFF';
		$serverinfo['upinfo'] = @ini_get('file_uploads') ? ini_get('upload_max_filesize') : '<font color="red">' . $this->lng['management_login_phpinfo07'] . '</font>';
		$serverinfo['gdver'] = GD_VERSION;
		$serverinfo['register'] = @ini_get('register_globals') ? 'ON' : 'OFF';
		$serverinfo['safemode'] = @ini_get('safe_mode') ? 'ON' : 'OFF';
		$serverinfo['sqlver'] = mysql_get_server_info();
		$serverinfo['gzip'] = strstr($_SERVER["HTTP_ACCEPT_ENCODING"], "gzip") ? 'ON' : 'OFF';

		$db_table = db_prefix . 'lng';
		$db_where = "isopen=1 ORDER BY pid DESC,id DESC";
		$sql = ('SELECT id,lngtitle,lng FROM ' . $db_table . ' WHERE ' . $db_where);
		$rs = $this->db->query($sql);
		while ($rsLanlist = $this->db->fetch_assoc($rs)) {
			$lngarray[] = $rsLanlist;
		}
		$this->ectemplates->assign('lngarray', $lngarray);
		$this->ectemplates->assign('powerinfo', $rsPower);
		$this->ectemplates->assign('serverinfo', $serverinfo);
		$this->ectemplates->assign('hellostr', $this->fun->get_timemessage(time()));
		$this->ectemplates->display('admin/admin_center');
	}

	function onpassword() {
		parent::start_template();
		$db_table = db_prefix . 'admin_member';
		$db_where = 'id=' . $this->esp_adminuserid . ' and username=\'' . $this->esp_username . '\' and isclass=1';
		$rsMember = $this->db->fetch_first('SELECT id,username,password,name,sex,outtime,ipadd FROM ' . $db_table . ' WHERE ' . $db_where);
		$this->ectemplates->assign('memberinfo', $rsMember);
		$this->ectemplates->display('admin/admin_password');
	}

	function oneditpassword() {
		parent::start_template();
		$db_table = db_prefix . 'admin_member';
		$password1 = md5($this->fun->accept('password1', 'P'));
		$passwordlog = $this->fun->accept('password1', 'P');
		$password = md5($this->fun->accept('password', 'P'));
		$name = $this->fun->accept('name', 'P');
		$sex = $this->fun->accept('sex', 'P');
		$db_where = 'id=' . $this->esp_adminuserid . ' and username=\'' . $this->esp_username . '\' and password=\'' . $password1 . '\' and isclass=1';
		$rsMember = $this->db->fetch_first('SELECT id FROM ' . $db_table . ' WHERE ' . $db_where);
		if (!$rsMember) {
			$errconter = $this->lng['management_password_password_error'];
			$this->writelog($this->lng['management_password_log'], $this->lng['log_extra_no'] . ' user=' . $this->esp_username . ' password=' . $passwordlog);
		} else {
			$db_set = "password='$password',name='$name',sex=$sex";
			$this->db->query('UPDATE ' . $db_table . ' SET ' . $db_set . ' WHERE ' . $db_where);
			$this->writelog($this->lng['management_password_log'], $this->lng['log_extra_ok']);
			$this->calldialogmessage($this->lng['management_password_message'], $this->lng['message_botton'], '', 0, 1, 'locationout');
		}
		$db_where = 'id=' . $this->esp_adminuserid . ' and username=\'' . $this->esp_username . '\' and isclass=1';
		$rsMember = $this->db->fetch_first('SELECT id,username,password,name,sex,outtime,ipadd FROM ' . $db_table . ' WHERE ' . $db_where);
		$this->ectemplates->assign('memberinfo', $rsMember);
		$this->ectemplates->assign('errconter', $errconter);
		$this->ectemplates->display('admin/admin_password');
	}
	//后台管理转到这里开始执行
	function ontab() {
		parent::start_template();
		$loadfun = $this->fun->accept('loadfun', 'G');  //开始加载函数
		if (empty($loadfun)) {
			exit('err');
		}
		$mid = $this->fun->accept('mid', 'G');
		include_once admin_ROOT . adminfile . '/include/command_list.php';

		$menuid = $this->fun->accept('menuid', 'R');
		$menuid = empty($menuid) ? 31 : $menuid;

		$tab['url'] = $CONLIST[$loadfun]['tabloadurl'];

		$tab['title'] = $CONLIST[$loadfun]['tabloadtitle'];
		$this->ectemplates->assign('tab', $tab);
		$this->ectemplates->assign('menuid', $menuid);
		$this->ectemplates->display('admin/admin_tab');
	}
	//接着切换到这里开始继续执行
	function onlist() {
		include_once admin_ROOT . adminfile . '/include/command_list.php';
		parent::start_template();
		$listfunction = $this->fun->accept('listfunction', 'G');
		
		$lng = $this->fun->accept('lng', 'G');
		$lng = empty($lng) ? ($this->CON['is_alonelng'] && !empty($this->CON['home_lng'])) ? $this->CON['home_lng'] : $this->CON['default_lng'] : $lng;
		$mid = $this->fun->accept('mid', 'G');
		$isclass = $this->fun->accept('isclass', 'G');
		if (empty($listfunction)) {
			exit('err');
		}

		$cookpage = $this->fun->accept($CONLIST[$listfunction]['pagecoock'], 'C');
		$nowpage = empty($cookpage) ? 0 : $cookpage;
		$this->ectemplates->assign('nowpage', $nowpage);
		if($listfunction == "orderloglist") {
			$orderid = $this->fun->accept('orderid', 'G');
			$this->ectemplates->assign('loadurl', $CONLIST[$listfunction]['loadurl'].$orderid);
		} else {
			$this->ectemplates->assign('loadurl', $CONLIST[$listfunction]['loadurl']);
		}
		$this->ectemplates->assign('MaxPerPage', $this->CON['max_list']);

		$this->ectemplates->assign('MaxHit', $this->CON['max_page']);
		$this->ectemplates->assign('listtype', $listtype);
		$this->ectemplates->assign('listfunction', $listfunction);
		$this->ectemplates->assign('lng', $lng);
		$this->ectemplates->assign('mid', $mid);
		$this->ectemplates->assign('isclass', $isclass);
		$this->ectemplates->display('admin/admin_tab_list');
	}

	function onloglist() {
		parent::start_template();

		$MinPageid = intval($this->fun->accept('MinPageid', 'R'));
		$loguser = $this->fun->accept('loguser', 'R');
		$orderid = $this->fun->accept('orderid', 'R');
		$counttype = $this->fun->accept('countnum', 'R');

		$page_id = intval($this->fun->accept('page_id', 'R'));
		$MaxPerPage = intval($this->fun->accept('MaxPerPage', 'R'));
		if (empty($MaxPerPage)) {
			$MaxPerPage = $this->CON['max_list'];
		}

		$db_table = db_prefix . 'logs';
		if (!empty($loguser)) {
			$db_where = ' WHERE username=\'' . $loguser . '\'';
		}
		if(!empty($orderid)) {
			$db_where = ' WHERE orderid=' . $orderid . '';
		}
		if (!empty($counttype)) {

			$countnum = $this->db_numrows($db_table, $db_where);
			exit($countnum);
		}
		$sql = 'SELECT id,username,onlineip,addtime,actions,remarks FROM ' . $db_table . $db_where . ' ORDER BY id DESC LIMIT ' . $MinPageid . ',' . $MaxPerPage;
		$rs = $this->db->query($sql);
		while ($rsList = $this->db->fetch_assoc($rs)) {
			$array[] = $rsList;
		}

		$this->fun->setcookie($this->fun->noncefile() . 'pgid', $page_id, 600);
		$this->ectemplates->assign('array', $array);
		$this->ectemplates->display('admin/admin_log_list');
	}

	function onmangerlist() {
		$this->powercheck(1, 2);
		parent::start_template();

		$MinPageid = intval($this->fun->accept('MinPageid', 'R'));
		$loguser = $this->fun->accept('loguser', 'R');

		$page_id = intval($this->fun->accept('page_id', 'R'));

		$countnum = $this->fun->accept('countnum', 'R');
		$MaxPerPage = intval($this->fun->accept('MaxPerPage', 'R'));
		if (empty($MaxPerPage)) {
			$MaxPerPage = $this->CON['max_list'];
		}
		$wheretext = null;
		$isclass = intval($this->fun->accept('isclass', 'R'));
		$inputclassid = intval($this->fun->accept('inputclassid', 'R'));
		$powergroup = intval($this->fun->accept('powergroup', 'R'));
		if (!empty($isclass)) {
			if ($isclass == 2) $isclass = 0;
			$wheretext.=' AND isclass=' . $isclass;
		}
		if (!empty($inputclassid)) {
			if ($inputclassid == 2) $inputclassid = 0;
			$wheretext.=' AND inputclassid=' . $inputclassid;
		}
		if (!empty($powergroup)) {
			$wheretext.=' AND powergroup=' . $powergroup;
		}
		$db_where = " WHERE id>0" . $wheretext;
		$db_table = db_prefix . 'admin_member';
		if (!empty($countnum)) {

			$countnum = $this->db_numrows($db_table, $db_where);
			exit($countnum);
		}
		$sql = 'SELECT id,username,password,name,sex,intotime,intime,outtime,ipadd,hit,powergroup,inputclassid,isclass FROM ' . $db_table . $db_where . ' ORDER BY id DESC LIMIT ' . $MinPageid . ',' . $MaxPerPage;
		$rs = $this->db->query($sql);
		while ($rsList = $this->db->fetch_assoc($rs)) {
			$rsList['powername'] = $this->get_power_view($rsList['powergroup'], 'powername');
			$array[] = $rsList;
		}

		$this->fun->setcookie($this->fun->noncefile() . 'pgid', $page_id, 600);
		$this->ectemplates->assign('array', $array);
		$this->ectemplates->assign('sql', $sql);
		$this->ectemplates->display('admin/admin_manager_list');
	}

	function onload() {
		$this->start_template();

		$this->ectemplates->assign('calltitle', $calltitle);

		$this->ectemplates->assign('bottonName', $bottonName);
		$this->ectemplates->display('admin/admin_load');
	}

	function onmanageradd() {
		parent::start_template();

		$tab = $this->fun->accept('tab', 'G');
		$tab = empty($tab) ? 'true' : $tab;

		$powergrouplist = $this->get_power_array();
		$this->ectemplates->assign('powerlist', $powergrouplist['list']);
		$this->ectemplates->assign('tab', $tab);
		$this->ectemplates->display('admin/admin_manager_add');
	}

	function onmanageedit() {
		parent::start_template();
		$db_table = db_prefix . 'admin_member';
		$id = intval($this->fun->accept('id', 'G'));
		$copytype = $this->fun->accept('copytype', 'G');
		$db_where = 'id=' . $id;
		$rsMember = $this->db->fetch_first('SELECT * FROM ' . $db_table . ' WHERE ' . $db_where);
		$powergrouplist = $this->get_power_array($rsMember['powergroup']);
		$this->ectemplates->assign('tab', 'true');
		$this->ectemplates->assign('memberinfo', $rsMember);
		$this->ectemplates->assign('copytype', $copytype);
		$this->ectemplates->assign('powerlist', $powergrouplist['list']);
		$this->ectemplates->display('admin/admin_manager_edit');
	}

	function onmanagesava() {
		$db_table = db_prefix . 'admin_member';
		$inputclass = $this->fun->accept('inputclass', 'P');
		$username = $this->fun->accept('username', 'R');
		if (!preg_match("/^[a-zA-Z]{1}[a-zA-Z0-9]{4,19}$/i", $username)) {
			exit('false');
		}
		$password = md5($this->fun->accept('password', 'P'));
		$passwordlog = $this->fun->accept('password', 'P');
		$name = $this->fun->accept('name', 'P');
		$sex = $this->fun->accept('sex', 'P');
		$powergroup = intval($this->fun->accept('powergroup', 'P'));
		$inputclassid = intval($this->fun->accept('inputclassid', 'P'));
		if ($inputclass == 'add') {
			$this->powercheck(1, 3);
			$date = time();
			$ipadd = $this->fun->ip($_SERVER['REMOTE_ADDR']);
			$db_field = 'username,password,name,sex,intotime,intime,outtime,ipadd,hit,powergroup,inputclassid,isclass';
			$db_values = "'$username','$password','$name',$sex,$date,0,0,$ipadd,0,$powergroup,$inputclassid,1";
			$this->db->query('INSERT INTO ' . $db_table . ' (' . $db_field . ') VALUES (' . $db_values . ')');
			$this->writelog($this->lng['mangerlist_add_log'], $this->lng['log_extra_ok'] . ' user=' . $username);
			exit('true');
		}

		if ($inputclass == 'edit') {
			$this->powercheck(1, 35);
			$id = $this->fun->accept('id', 'P');
			$db_where = "id=$id";
			$db_set = "name='$name',sex=$sex,powergroup=$powergroup,inputclassid=$inputclassid";
			if (!empty($passwordlog)) {
				$db_set.=",password='$password'";
			}
			$this->db->query('UPDATE ' . $db_table . ' SET ' . $db_set . ' WHERE ' . $db_where);
			$this->writelog($this->lng['mangerlist_edit_log'], $this->lng['log_extra_ok'] . ' user=' . $username);
			exit('true');
		}
	}

	function onusercheck() {
		$db_table = db_prefix . 'admin_member';
		$username = $this->fun->accept('username', 'R');
		if (!preg_match("/^[a-zA-Z]{1}[a-zA-Z0-9]{4,16}$/i", $username)) {
			exit('false');
		}
		$db_where = "username='$username'";
		$rs = $this->db->query('SELECT username FROM ' . $db_table . ' WHERE ' . $db_where);
		$rsList = $this->db->fetch_assoc($rs);
		if (!$rsList) {
			exit('true');
		} else {
			exit('false');
		}
	}

	function ondelmanage() {
		$this->powercheck(1, 33);
		$db_table = db_prefix . 'admin_member';
		$selectinfoid = $this->fun->accept('selectinfoid', 'P');
		if (empty($selectinfoid)) exit('false');
		$infoarray = explode(',', $selectinfoid);
		$count = count($infoarray) - 1;
		if ($count <= 0) exit('false');
		for ($i = 0; $i < $count; $i++) {
			$db_where = "id=$infoarray[$i]";
			$this->db->query('DELETE FROM ' . $db_table . ' WHERE ' . $db_where);
		}
		$this->writelog($this->lng['mangerlist_del_log'], $this->lng['log_extra_ok'] . ' userid=' . $selectinfoid);
		exit('true');
	}

	function onsetting() {
		$this->powercheck(1, 34);
		$db_table = db_prefix . 'admin_member';
		$selectinfoid = $this->fun->accept('selectinfoid', 'P');
		$selectinfoid = $selectinfoid . '0';
		if (empty($selectinfoid)) exit('false');

		$value = $this->fun->accept('value', 'P');

		$dbname = $this->fun->accept('dbname', 'P');
		$db_set = "$dbname=$value";
		$db_where = "id IN ( $selectinfoid )";
		$this->db->query('UPDATE ' . $db_table . ' SET ' . $db_set . ' WHERE ' . $db_where);
		$this->writelog($this->lng['mangerlist_isclass_log'], $this->lng['log_extra_ok'] . ' userid=' . $selectinfoid);
		exit('true');
	}
	
	function oncitysetting() {
		parent::start_template();
		$this->powercheck(1, 34);
		$tab = $this->fun->accept('tab', 'G');
		$tab = empty($tab) ? 'true' : $tab;
		$groupid = $this->fun->accept('groupid', 'G');
		$groupid = empty($groupid) ? 10 : $groupid;
		
		$this->ectemplates->assign('tab', $tab);
		$this->ectemplates->assign('groupid', $groupid);
		$this->ectemplates->assign('subname', subname);
		$this->ectemplates->assign('hcitylist', hcitylist);
		$this->ectemplates->display('admin/admin_manager_citysetting');
	}

	function onsysinfo() {
		parent::start_template();

		$templatesdirsize = $this->fun->format_size($this->fun->dirsize(admin_ROOT . '/cache/admin/templates'));

		$cachedirsize = $this->fun->format_size($this->fun->dirsize(admin_ROOT . '/cache/admin/cache'));

		$backupdirsize = $this->fun->format_size($this->fun->dirsize(admin_ROOT . '/public/backup/'));

		$upfiledirsize = $this->fun->format_size($this->fun->dirsize("../upfile/"));

		$serverinfo = PHP_OS . ' / PHP v' . PHP_VERSION;
		$dbversion = $this->db->version();
		$fileupload = @ini_get('file_uploads') ? ini_get('upload_max_filesize') : '<font color="red">' . $lang['no'] . '</font>';
		$query = $tables = $this->db->fetch_all("SHOW TABLE STATUS LIKE '$tablepre%'");
		foreach ($tables as $table) {
			$dbsize+=$table['Data_length'] + $table['Index_length'];
		}

		$serverip = $_SERVER['SERVER_ADDR'];

		$web_server = $_SERVER['SERVER_SOFTWARE'];
		$this->ectemplates->assign('lngselect', $this->lngselect($lng));
		$this->ectemplates->assign('templatesdirsize', $templatesdirsize);
		$this->ectemplates->assign('cachedirsize', $cachedirsize);
		$this->ectemplates->assign('backupdirsize', $backupdirsize);
		$this->ectemplates->assign('upfiledirsize', $upfiledirsize);
		$this->ectemplates->assign('getGPC', get_magic_quotes_gpc());
		$this->ectemplates->assign('md5link', md5(time()));

		$this->ectemplates->assign('serverinfo', $serverinfo);
		$this->ectemplates->assign('serverip', $serverip);
		$this->ectemplates->assign('web_server', $web_server);

		$this->ectemplates->assign('dbversion', $dbversion);

		$this->ectemplates->assign('fileupload', $fileupload);

		$this->ectemplates->assign('dbsize', $this->fun->format_size($dbsize));
		$this->ectemplates->assign('skintitle', $this->lng);
		$this->ectemplates->display('admin/admin_sysinfo');
	}

	function onlinkecisp() {
		parent::start_template();
		$getnetval = convert_uudecode($this->CON['getnetval']);
		$xmlfile = $getnetval . 'sitemap/rss_news.xml';

		$inforss = @simplexml_load_file($xmlfile, 'SimpleXMLElement', LIBXML_NOCDATA);

		$this->fun->objectToArray($inforss);

		$outrssinfo = $inforss['channel']['item'];
		$this->ectemplates->assign('array', $outrssinfo);
		$this->ectemplates->assign('infoclass', 'news');
		$this->ectemplates->display('admin/admin_xmlinfo');
	}

	function onverecisp() {
		parent::start_template();
		$getnetval = convert_uudecode($this->CON['getnetval']);
		$xmlfile = $getnetval . 'sitemap/rss_news.xml';

		$inforss = @simplexml_load_file($xmlfile, 'SimpleXMLElement', LIBXML_NOCDATA);
		$this->fun->objectToArray($inforss);
		$this->ectemplates->assign('valinfo', $inforss['channel']['val']);
		$this->ectemplates->assign('softmessage', $inforss['channel']['softmessage']);
		$this->ectemplates->assign('softurl', $inforss['channel']['softurl']);
		$this->ectemplates->assign('infoclass', 'val');
		$this->ectemplates->display('admin/admin_xmlinfo');
	}
	//软件更新信息
	function onsoftupdate() {
		parent::start_template();
		$getnetval = convert_uudecode($this->CON['getnetval']);
		$d = $this->CON['domain'];
		$updatefile = $getnetval . 'products/ydb-checkupdate.aspx?currentVersion='.db_version.'&d='.$d;
		$iscurl = function_exists('curl_exec')? true : false;  //是否支持curl
		$result = "";
		if($iscurl) {
			$result = $this->fun->get_curl($updatefile);
		} else {
			$result = $this->fun->get_remotefile($updatefile);
		}
		include_once admin_ROOT . 'public/class_json.php';
		$isjson = function_exists('json_decode')? true : false;
		if($isjson) {
			$arr = json_decode($result,true);
		} else {
			$json = new json();
			$arr = $json->jsonDecode($result);
		}
		$outstr = "";
		if($arr['Status']==1) {
			$outstr = '<div class="suggestion">
				<span class="sugicon">
					<span class="strong colorgorning2">温馨提醒：</span>
					<span class="colorgorningage">预订宝酒店预订系统已经升级，请下载！</span>
					<span class="padding-left5 strong colorgorning2">最新版本：</span>
					<span class="colorgorningage">'.$arr['NewVersion'].'</span>
					<span class="padding-left5 colorgorning2"><a href="'.$arr['UpdateUrl'].'" target="_blank">点击下载</a></span>
				</span>
				</div>';
		}
		echo $outstr;
		exit;
	}

	function onauthentication() {
		parent::start_template();
		$ipadd = $this->fun->ip($_SERVER['REMOTE_ADDR']);
		$getnetval = convert_uudecode($this->CON['getnetval']);
		$xmlfile = $getnetval . 'index.php?ac=siteauthentication&at=join&siteurl=' . urlencode($this->CON['domain']) . '&sitename=' . urlencode($this->CON['sitename']) . '&iplong=' . $ipadd;

		$inforss = @simplexml_load_file($xmlfile, 'SimpleXMLElement', LIBXML_NOCDATA);
		$this->fun->objectToArray($inforss);
	}

	function onclearlog() {
		parent::start_template();
		$execute = $this->fun->accept('execute', 'R');
		if ($execute == 1) {
			$deltype = $this->fun->accept('deltype', 'R');
			$username = $this->fun->accept('username', 'R');
			$db_table = db_prefix . 'logs';
			if (!$deltype) {
				$db_where = " WHERE username='$username'";
			}
			$this->db->query('DELETE FROM ' . $db_table . $db_where);
			$this->writelog($this->lng['clear_log_del_log'], $this->lng['log_extra_ok']);
			exit('true');
		}
		$this->ectemplates->display('admin/admin_clear_log');
	}

	function onclearcache() {
		parent::start_template();
		$execute = $this->fun->accept('execute', 'P');
		$delindex = admin_ROOT . "html/". $this->CON['entrance_file'] .'.'.$this->CON['file_fileex'];
		if (file_exists($delindex)) {
			$this->fun->delfile($delindex);
		}
		if (!empty($execute)) {
			if (!$this->CON['is_caching']) {
				exit('close');
			}
			$retrun = $this->dbcache->clearcache();
			if ($retrun) {
				exit('true');
			} else {
				exit('false');
			}
		}
		$this->ectemplates->display('admin/admin_manager_clearcache');
	}

	function onfilecheck() {
		parent::start_template();
		$execute = $this->fun->accept('execute', 'R');

		$file_htmldir = admin_ROOT . $this->CON['file_htmldir'];

		$file_sitemapdir = admin_ROOT . $this->CON['file_sitemapdir'];

		$file_sqlbakdir = admin_ROOT . $this->CON['file_sqlbakdir'];

		$upfile_dir = admin_ROOT . $this->CON['upfile_dir'];

		$cache_dir = admin_ROOT . "datacache/";
		$cache_dirlist = array(
		    0 => array('dir' => 'datacache/dbcache/', 'key' => '1'),
		    1 => array('dir' => 'datacache/admin/cache/', 'key' => '1'),
		    2 => array('dir' => 'datacache/admin/templates/', 'key' => '1'),
		    3 => array('dir' => 'datacache/main/cache/', 'key' => '1'),
		    4 => array('dir' => 'datacache/pic/', 'key' => '1'),
		    5 => array('dir' => 'datacache/main/templates/', 'key' => '1')
		);
		if ($execute == 1) {
			$str = '{';
			if (!$this->fun->filemode($file_htmldir)) {
				$str .='"htmldir":"false",';
			} else {
				$str .='"htmldir":"true",';
			}
			if (!$this->fun->filemode($file_sitemapdir)) {
				$str .='"sitemapdir":"false",';
			} else {
				$str .='"sitemapdir":"true",';
			}
			if (!$this->fun->filemode($file_sqlbakdir)) {
				$str .='"sqlbakdir":"false",';
			} else {
				$str .='"sqlbakdir":"true",';
			}
			if (!$this->fun->filemode($upfile_dir)) {
				$str .='"upfiledir":"false",';
			} else {
				$str .='"upfiledir":"true",';
			}
			$filestr = '';
			foreach ($cache_dirlist as $key => $value) {
				if (!$this->fun->filemode(admin_ROOT . $value['dir'])) {
					$cache_dirlist[$key]['key'] = '0';
					$filestr .='0';
				} else {
					$cache_dirlist[$key]['key'] = '1';
					$filestr .='1';
				}
			}
			if ($filestr == '111111') {
				$str .='"cachedir":"true",';
			} else {
				$str .='"cachedir":"false",';
			}
			$str .='"cachedirkey":"' . $filestr . '"';
			$str.='}';
			exit($str);
		}
		$filedirlist = array(
		    'htmldir' => $this->CON['file_htmldir'],
		    'sitemapdir' => $this->CON['file_sitemapdir'],
		    'sqlbakdir' => $this->CON['file_sqlbakdir'],
		    'upfiledir' => $this->CON['upfile_dir'],
		    'cachedir' => "/datacache/",
		);
		$this->ectemplates->assign('filedirlist', $filedirlist);
		$this->ectemplates->assign('cachelist', $cache_dirlist);
		$this->ectemplates->display('admin/admin_manager_filecheck');
	}

	function onsyssetting() {
		parent::start_template();
		$db_table = db_prefix . 'config';
		$tab = $this->fun->accept('tab', 'G');
		$tab = empty($tab) ? 'true' : $tab;
		$groupid = $this->fun->accept('groupid', 'G');
		$groupid = empty($groupid) ? 2 : $groupid;
		$db_where = " WHERE groupid=$groupid";
		$sql = 'SELECT id,pid,valname,content,str,value,valtype,bottonname,groupid FROM ' . $db_table . $db_where . ' ORDER BY pid,groupid';
		$rs = $this->db->query($sql);
		while ($rsList = $this->db->fetch_assoc($rs)) {
			if ($rsList['valtype'] == 'bool') {
				$bottonname = array();
				$bottonname = explode(',', $rsList['bottonname']);
				$rsList['b1'] = $bottonname[0];
				$rsList['b2'] = $bottonname[1];
			}
			$array[] = $rsList;
		}
		$tongji = "";
		if (file_exists(admin_ROOT . 'datacache/tongji.php')) {
			include_once admin_ROOT . 'datacache/tongji.php';
		}
		$this->ectemplates->assign('tab', $tab);
		$this->ectemplates->assign('tongji', stripslashes($tongji));
		$this->ectemplates->assign('groupid', $groupid);
		$this->ectemplates->assign('array', $array);
		$this->ectemplates->display('admin/admin_manager_setting');
	}
	
	function oncitysetsave() {
		$this->powercheck(15, 0);
		$groupid = $this->fun->accept('groupid', 'P');
		if (empty($groupid)) {
			exit('{"post":"false","groupid":"' . $groupid . '"}');
		}
		$subname = $this->fun->accept('subname', 'P');
		$hcitylist = $this->fun->accept('hcitylist', 'P');
		$filename = admin_ROOT . 'datacache/public.php';
		
		$config = "<?php \r\ndefine('db_host', '".db_host."');\r\n";
		$config .= "define('db_user', '".db_user."');\r\n";
		$config .= "define('db_pw', '".db_pw."');\r\n";
		$config .= "define('db_name', '".db_name."');\r\n";
		$config .= "define('db_charset', '" . db_charset . "');\r\n";
		$config .= "define('db_prefix', '".db_prefix."');\r\n";
		$config .= "define('db_lan', '".db_lan."');\r\n";
		$config .= "define('headcharset', '".headcharset."');\r\n";
		$config .= "define('db_version', '" . db_version . "');\r\n";
		$config .= "define('subname','".$subname."');\r\n";
		$config .= "define('hcitylist', '".$hcitylist."');\r\n";
		$config .= "define('hotelorder_aid', '".hotelorder_aid."');\r\n";
		$config .= "define('hotelorder_key', '".hotelorder_key."');\r\n";
		$config .= "define('db_keycode', '".db_keycode."');\r\n";
		$config .= "define('db_pscode', '" . db_pscode . "');\r\n";
		$config .= "define('softtitle', '" . softtitle . "');\r\n?>";
		$fp = fopen($filename, 'w');
		fwrite($fp, $config);
		fclose($fp);
		
		$delindex = admin_ROOT . "html/". $this->CON['entrance_file'] .'.'.$this->CON['file_fileex'];
		if (file_exists($delindex)) {
			$this->fun->delfile($delindex);
		}
		$this->systemfile(true);
		
		exit('{"post":"true","groupid":"' . $groupid . '"}');
	}

	function onsetsave() {
		$this->powercheck(15, 0);
		$db_table = db_prefix . 'config';
		$groupid = $this->fun->accept('groupid', 'P');
		if (empty($groupid)) {
			exit('{"post":"false","groupid":"' . $groupid . '"}');
		}
		$cache_dir = admin_ROOT . "datacache/";
		if (!$this->fun->filemode($cache_dir)) {
			exit('{"post":"false","groupid":"' . $groupid . '"}');
		}
		$commandfile = admin_ROOT . 'datacache/command.php';
		if (@is_file($commandfile)) {
			if (!unlink($commandfile)) {
				exit('{"post":"false","groupid":"' . $groupid . '"}');
			}
		}
		$db_where = " WHERE groupid=$groupid";
		$sql = 'SELECT id,valname,value FROM ' . $db_table . $db_where . ' ORDER BY groupid';
		$rs = $this->db->query($sql);
		while ($rsList = $this->db->fetch_assoc($rs)) {
			$db_set = "value='" . $this->fun->accept($rsList['valname'], 'P') . "'";
			$db_where = 'id=' . $rsList['id'];
			$this->db->query('UPDATE ' . $db_table . ' SET ' . $db_set . ' WHERE ' . $db_where);
		}
		$delindex = admin_ROOT . "html/". $this->CON['entrance_file'] .'.'.$this->CON['file_fileex'];
		if (file_exists($delindex)) {
			$this->fun->delfile($delindex);
		}
		$this->dbcache->clearcache();
		$this->systemfile(true);
		if($groupid==2) {
			$tjurl = admin_ROOT . 'datacache/tongji.php';
			$tongji = "<?php\n";
			$tongji .= "\$tongji='".$this->fun->accept('tongji', 'P')."';\n";
			$tongji .= "?>";
			$this->fun->filewrite($tjurl, $tongji);
		}
		$this->writelog($this->lng['setting_edit_log'], $this->lng['log_extra_ok'] . 'groupid=' . $groupid);
		exit('{"post":"true","groupid":"' . $groupid . '"}');
	}

}
?>